package esiag.pds.Test;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javolution.util.FastList;

import junit.framework.Assert;

import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import esiag.pds.beans.Information;
import esiag.pds.beans.Parameters;
import esiag.pds.contextManagement.Context;
import esiag.pds.receivers.ReplicationReceiver;

public class TestSameContext {

	 public void prepareContext(Context context) {
		 FastList<Serializable>l0=new FastList<>();
			l0.add(new Information());
			l0.add(new Information());
			context.addList(l0);
			
			FastList<Serializable>l1=new FastList<>();
			l1.add(new Information());
			l1.add(new Information());
			l1.add(new Information());
			
			context.addList(l1);
			
			FastList<Serializable>l2=new FastList<>();
			l2.add(new Information());
			l2.add(new Information());
			l2.add(new Information());
			l2.add(new Information());
			context.addList(l2);
			
			FastList<Serializable>l3=new FastList<>();
			l3.add(new Information());
			l3.add(new Information());
			l3.add(new Information());
			l3.add(new Information());
			context.addList(l3);
		}

	@Test
	public void testReplicationClient(){
		 XmlBeanFactory factory=new XmlBeanFactory(new ClassPathResource("Parameters.xml"));
		 Parameters param=factory.getBean("parameters",Parameters.class);
		
		 Context localContext=new Context();
		prepareContext(localContext);
	
		ReplicationReceiver rr=new ReplicationReceiver(param.getPort());
		
		Assert.assertTrue(localContext.isTheSameAs(rr.rmiWork())==true);
	
	}
	

}
